package java111;

import java.util.*;

public class Day6 {
    // 大数加法
    // https://www.nowcoder.com/practice/11ae12e8c6fe48f883cad618c2e81475?tpId=196&tqId=37176&ru=/exam/oj
    public String solve (String s, String t) {
        // write code here
        int tmp = 0;
        StringBuilder sb = new StringBuilder();
        int i = s.length()-1, j = t.length()-1;
        while(tmp != 0 || i >= 0 || j >= 0){
            if(i >= 0){
                tmp += s.charAt(i--) - '0';
            }
            if(j >= 0){
                tmp += t.charAt(j--) - '0';
            }
            sb.append(tmp % 10);
            tmp /= 10;
        }
        return sb.reverse().toString();
    }


    // 链表相加
    public static class ListNode {
        int val;
        ListNode next = null;

        public ListNode(int val) {
            this.val = val;
        }
    }

    public static void main1(String[] args) {
        ListNode node1 = new ListNode(9);
        ListNode node2 = new ListNode(3);
        ListNode node3 = new ListNode(7);
        ListNode node4 = new ListNode(6);
        ListNode node5 = new ListNode(3);
        node1.next = node2;
        node2.next = node3;
        node4.next = node5;
        ListNode ret = addInList(node1, node4);
    }

    public static ListNode addInList(ListNode head1, ListNode head2) {
        // write code here
        // 反转链表head1
        ListNode newhead1 = new ListNode(0);
        while (head1.next != null) {
            ListNode tmp = head1.next;
            head1.next = newhead1.next;
            newhead1.next = head1;
            head1 = tmp;
        }
        head1.next = newhead1.next;
        newhead1.next = null;

        // 反转链表head2
        ListNode newhead2 = new ListNode(0);
        while (head2.next != null) {
            ListNode tmp = head2.next;
            head2.next = newhead2.next;
            newhead2.next = head2;
            head2 = tmp;
        }
        head2.next = newhead2.next;
        newhead2.next = null;
        // 链表对应值相加
        int tmp = 0;
        ListNode retHead = new ListNode(-1);
        ListNode ret = retHead;
        while (head1 != null && head2 != null) {
            int res = head1.val + head2.val + tmp;
            if (res >= 10) {
                tmp = 1;
                res %= 10;
            } else {
                tmp = 0;
            }
            ListNode tmpNode = new ListNode(res);
            retHead.next = tmpNode;
            retHead = tmpNode;
            head1 = head1.next;
            head2 = head2.next;
        }
        while (head1 != null) {
            int res = head1.val + tmp;
            if (res >= 10) {
                tmp = 1;
                res %= 10;
            } else {
                tmp = 0;
            }
            ListNode tmpNode = new ListNode(res);
            retHead.next = tmpNode;
            retHead = tmpNode;
            head1 = head1.next;
        }
        while (head2 != null) {
            int res = head2.val + tmp;
            if (res >= 10) {
                tmp = 1;
                res %= 10;
            } else {
                tmp = 0;
            }
            ListNode tmpNode = new ListNode(res);
            retHead.next = tmpNode;
            retHead = tmpNode;
            head2 = head2.next;
        }
        // 反转结果链表
        ListNode newhead3 = new ListNode(0);
        ListNode head3 = ret.next;
        while (head3.next != null) {
            ListNode tmpN = head3.next;
            head3.next = newhead3.next;
            newhead3.next = head3;
            head3 = tmpN;
        }
        head3.next = newhead3.next;
        newhead3.next = null;
        return head3;
    }


    // 大数乘法
    //https://www.nowcoder.com/practice/6b668316f0ac4421ae86d7ead4301b42?tpId=182&tqId=34662&ru=/exam/oj
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String s = in.next();
            String t = in.next();
            StringBuilder sb = new StringBuilder();
            int max = Math.max(s.length(), t.length());
            String[] arr1 = new String[max *2];
            for(int i = 0; i < t.length(); i++){
                for(int j = 0; j < s.length(); j++) {
                    int index = (t.length() - 1 - i) + (s.length() - 1 - j);
                    int tmp = (s.charAt(j) - '0') * (t.charAt(i) - '0');
                    if(arr1[index] == null){
                        arr1[index] = tmp + "";
                    } else {
                        arr1[index] = Integer.parseInt(arr1[index]) + tmp + "";
                    }
                }
            }
            int tmp = 0;
            for (int i = 0; i < arr1.length; i++) {
                if (arr1[i] != null) {
                    int res = Integer.parseInt(arr1[i]) + tmp;
                    sb.append(res % 10);
                    tmp = res / 10;
                }
            }
            sb.append(tmp);
            sb.reverse();
            System.out.println(sb);
        }
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String s = in.next();
            String t = in.next();
            char[] chars1 = new StringBuilder(s).reverse().toString().toCharArray();
            char[] chars2 = new StringBuilder(t).reverse().toString().toCharArray();
            int[] res = new int[s.length() + t.length()];
            int tmp = 0;
            for(int i = 0; i < chars1.length; i++){
                for(int j = 0; j < chars2.length; j++){
                    res[i+j] += (chars1[i] - '0') * (chars2[j] - '0');
                }
            }
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < res.length; i++){
                res[i] += tmp;
                sb.append(res[i] % 10);
                tmp = res[i] / 10;
            }
            sb.append(tmp);
            while(sb.length() > 1 && sb.charAt(sb.length()-1) == '0'){
                sb.deleteCharAt(sb.length()-1);
            }
            System.out.println(sb.reverse());
        }
    }

}
